import { getMvDetail, getMvDetailInfo, getMvUrl, getMvComments, getMvRelated, getPersonalizedMv } from '../../api/services/api'
export default ({
    namespaced: true,
    state: {
        mvsPlayUrl: '',
        loading: false,
        mvRelatedList: [],
        mvInformation: {
            name: '',
            artists: [],
            publishTime: '',

        },
        mvLikeOrShare: {
            likeCount: 0,
            shareCount: 0,
        },
        mvCommentsPage: {
            currentPage: 1,
            limit: 20,
        },
        mvCommentData: {
            total: 0,
        },
        //推荐MV盒子
        personalizedMvList: [],
    },
    mutations: {
        changeMvUrl(state, val) {
            state.mvsPlayUrl = val;
        },
        changeMvRelatedList(state, val) {
            state.mvRelatedList = [...val];
        },
        changeMvInformation(state, val) {
            state.mvInformation = { ...val };
        },
        changeMvLikeOrShare(state, val) {
            state.mvLikeOrShare = { ...val };
        },
        changePersonalizedMvList(state, val) {
            state.personalizedMvList = [...val];
        },
        changeMvComments(state, val) {
            state.mvCommentData = { ...val };
        }

    },
    actions: {
        async getMvDetail(context, id) {
            const data = await getMvDetail(id);
            console.log('MV详情', data);
            context.commit('changeMvInformation', data.data);
        },
        async getMvDetailInfo(context, id) {
            const data = await getMvDetailInfo(id);
            console.log('MV获取mv点赞转发评论数数据', data);
            context.commit('changeMvLikeOrShare', data);

        },
        async getMvUrl(context, id) {
            const data = await getMvUrl(id);
            console.log('MV获取URl', data);
            context.commit('changeMvUrl', data.data.url);
        },
        async getMvComments(context, id) {
            const { currentPage, limit } = context.state.mvCommentsPage;
            const data = await getMvComments(id, limit, currentPage);
            console.log('MV评论数据', data);
            context.commit('changeMvComments', data);
        },
        async getMvRelated(context, id) {
            const data = await getMvRelated(id);
            console.log('相似mv', data);
            context.commit('changeMvRelatedList', data.mvs);
        },
        async getPersonalizedMv(context, val) {
            const data = await getPersonalizedMv();
            console.log('推荐的mv', data);
            context.commit('changePersonalizedMvList', data.result);
        }
    },

})